package com.cheng.example.java.version.java8.chap01_default;


/**
 * 01、默认方法
 */
interface Formula {
    double calculate(int a);

    default double sqrt(int a) {
        return Math.sqrt(a);
    }

}

public interface DefaultDemo01 {
    static void main(String[] args) {

        Formula formula = new Formula() {
            @Override
            public double calculate(int a) {
                return sqrt(a * 100);
            }
        };

        formula.calculate(100);     // 100.0
        System.out.println(formula.sqrt(16)); // 4.0

    }
}
